package com.example.yemiantiaozhuan;

import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ScrollView;

public class DActivity extends Activity {
    private Button hui;
    private MediaPlayer player;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.activity_d);
         hui=(Button)findViewById(R.id.hui);

playAudio();

         hui.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 Intent intent=new Intent();
                 intent.setClass(DActivity.this,AActivity.class);
                 startActivity(intent);
                 finish();}

         });
    }

    private void playAudio() {
        try {
            player = MediaPlayer.create(this, R.raw.luxiantuijian);
            player.start();
        } catch (IllegalStateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }  catch (Exception e) {
            e.printStackTrace();
        }

    }
    protected void onDestroy() {
        super.onDestroy();
        if (player!=null){
            player.release();
            player=null;
        }
    }
}